//
//  CLZWebviewViewController.m
//  ChunLaiZhuangClient
//
//  Created by zouzhisheng on 16/4/16.
//  Copyright © 2016年 CLZ. All rights reserved.
//

#import "CLZWebviewViewController.h"

@interface CLZWebviewViewController ()<UIWebViewDelegate>
@property(nonatomic,strong)UIWebView *webView;

@end

@implementation CLZWebviewViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _webView = [[UIWebView alloc] initWithFrame: CGRectMake(0, 0,SCREEN_WIDTH,SCREEN_HEIGHT-64)];
    _webView.delegate = self;
    _webView.scrollView.bounces = NO;
    _webView.scrollView.showsHorizontalScrollIndicator = NO;
    [_webView sizeToFit];
    [self setNaviLeftButton:@""];
    [self.view addSubview:_webView];
    [self loadWebView];
    // Do any additional setup after loading the view.
}
-(void)loadWebView{
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.webUrl]]];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)webViewDidStartLoad:(UIWebView *)webView{
    [[LKDHud shareHud] showLoadingView];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
    [[LKDHud shareHud] hideLoadingView];
    NSString *titile= [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
    [self setNaviTitle:titile];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(nullable NSError *)error{
      [[LKDHud shareHud] hideLoadingView];
}
-(void)clickLeftButton:(UIButton*)sender{
    if ([self.webView canGoBack]) {
        [self.webView goBack];
    }else{
        [self.navigationController popViewControllerAnimated:YES];
    }
    
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
